package org.binglan.youziyuepai.controller;

        import org.binglan.youziyuepai.exception.MyException;
        import org.binglan.youziyuepai.utils.ResponseVoUtils;
        import org.binglan.youziyuepai.vo.ResponseVo;
        import org.springframework.web.bind.annotation.ControllerAdvice;
        import org.springframework.web.bind.annotation.ExceptionHandler;
        import org.springframework.web.bind.annotation.ResponseBody;

        import javax.servlet.http.HttpServletRequest;

/**
 * @description:
 * @author: sanjin
 * @date: 2019/4/7 10:09
 */
@ControllerAdvice
public class GlobalExceptionController {


    /**
     * 全局异常处理
     * @param req
     * @param e
     * @return
     */
    @ExceptionHandler(MyException.class)
    @ResponseBody
    public ResponseVo defaultExceptionHandler(HttpServletRequest req, MyException e){
        return ResponseVoUtils.error(e.getMessage());
    }

}
